<!-- 网站信息 -->
<template>
  <div class="">
    <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
      <!-- <a-form-model-item ref="name" label="名称" prop="name">
                <a-input v-model="form.name" placeholder="请输入公司、组织或个人名称" />
            </a-form-model-item> -->
      <!-- <a-form-model-item label="业务">
                <a-input v-model="form.mainBusiness" placeholder="请输入主营业务" />
            </a-form-model-item> -->
      <a-form-model-item label="地址" prop="contactAddress">
        <a-input v-model="form.contactAddress" placeholder="请输入联系地址" />
      </a-form-model-item>
      <!-- <a-form-model-item label="QQ号">
                <a-input v-model="form.qq" placeholder="请填写QQ号码" />
            </a-form-model-item> -->
      <a-form-model-item label="电话号码" prop="tel">
        <a-input v-model="form.tel" placeholder="请输入电话号码" />
      </a-form-model-item>
      <a-form-model-item label="邮箱">
        <a-input v-model="form.email" placeholder="请输入邮箱地址" />
      </a-form-model-item>
      <a-form-model-item label="二维码">
        <UploadImg v-model="form.qrcodeUrl" cropper />
      </a-form-model-item>
      <a-form-model-item v-has="'web:webSite:edit'" :wrapper-col="{ span: 14, offset: 4 }">
        <a-button type="primary" style="margin-left: 10px" @click="onSubmit"> 保存 </a-button>
      </a-form-model-item>
    </a-form-model>
  </div>
</template>

<script>
import UploadImg from '@/components/UpFile/uploadImg'
import { setConfigWebsite } from '@/api/web/web'
export default {
  components: {
    UploadImg,
  },
  data() {
    return {
      labelCol: { span: 4 },
      wrapperCol: { span: 14 },
      loading: false,
      form: {
        // name: undefined,
        // mainBusiness: undefined,
        contactAddress: undefined,
        // qq: undefined,
        tel: undefined,
        email: undefined,
        qrcodeUrl: undefined,
      },
      rules: {
        // name: [{ required: true, message: '请输入网站名称', trigger: 'blur' }],
        contactAddress: [{ required: true, message: '请输入联系地址', trigger: 'blur' }],
        tel: [{ required: true, message: '请输入电话号码', trigger: 'blur' }],
      },
    }
  },
  computed: {},
  watch: {},
  methods: {
    setImage(url) {
      this.form.qrcodeUrl = url
    },
    onSubmit() {
      this.$refs.ruleForm.validate(async (valid) => {
        if (valid) {
          let { code, msg } = await setConfigWebsite(this.form)
          this.$message[code === 0 ? 'success' : 'error'](msg)
          if (code === 0) {
            this.$emit('update')
          }
        }
      })
    },
    resetForm() {},
  },
  created() {},
  mounted() {},
}
</script>
<style scoped>
</style>